package com.servlet.model.base;

import java.io.Serializable;

/**
 * Administrateur dans la base de données
 * comprend principalement les coefficient de pondération utilisés
 * ainsi que le mot de passe pour accéder à l'interface de l'administrateur.
 * @author Jing Jing
 */
public class Administrator implements Serializable {

	private String passwd;
	/**
	 * Coefficient pondérant la similarité des profils (âge et zone)
	 */
	private double coefProfile;
	/**
	 * Coefficient pondérant la similarité des études
	 */
	private double coefStudy;
	/**
	 * Coefficient pondérant la similarité des expériences proffessionnelles
	 */
	private double coefPro;
	
	private boolean is_modified_passwd;
	private boolean is_modified_coefProfile;
	private boolean is_modified_coefStudy;
	private boolean is_modified_coefPro;
	
	public Administrator()
	{
		this.passwd = null;
		this.coefPro = 0.0;
		this.coefProfile = 0.0;
		this.coefStudy = 0.0;
		is_modified_passwd = false;
		is_modified_coefProfile = false;
		is_modified_coefStudy = false;
		is_modified_coefPro = false;
	}
	
	public Administrator(String passwd, double coefPro, double coefProfile, double coefStudy)
	{
		this.passwd = passwd;
		this.coefPro = coefPro;
		this.coefProfile = coefProfile;
		this.coefStudy = coefStudy;
		is_modified_passwd = false;
		is_modified_coefProfile = false;
		is_modified_coefStudy = false;
		is_modified_coefPro = false;
	}
	
	/**
	 * GETTERS AND SETTERS
	 */
	public boolean getIs_modified_passwd() {
		return is_modified_passwd;
	}

	public boolean getIs_modified_coefProfile() {
		return is_modified_coefProfile;
	}

	public boolean getIs_modified_coefStudy() {
		return is_modified_coefStudy;
	}
	
	public boolean getIs_modified_coefPro() {
		return is_modified_coefPro;
	}
	
	public void setIs_modified_passwd(boolean is_modified_passwd) {
		this.is_modified_passwd = is_modified_passwd;
	}

	public void setIs_modified_coefProfile(boolean is_modified_coefProfile) {
		this.is_modified_coefProfile = is_modified_coefProfile;
	}

	public void setIs_modified_coefStudy(boolean is_modified_coefStudy) {
		this.is_modified_coefStudy = is_modified_coefStudy;
	}
	
	public void setIs_modified_coefPro(boolean is_modified_coefPro) {
		this.is_modified_coefPro = is_modified_coefPro;
	}
	
	public String getPasswd()
	{
		return this.passwd;
	}
	
	public void setPasswd(String passwd)
	{
		this.passwd = passwd;
	}
	
	public double getCoefProfile()
	{
		return this.coefProfile;
	}
	
	public void setCoefProfile(double coefProfile)
	{
		this.coefProfile = coefProfile;
		setIs_modified_coefProfile(true);
	}
	
	public double getCoefPro()
	{
		return this.coefPro;
	}
	
	public void setCoefPro(double coefPro)
	{
		this.coefPro = coefPro;
		setIs_modified_coefPro(true);
	}
	
	public double getCoefStudy()
	{
		return this.coefStudy;
	}
	
	public void setCoefStudy(double coefStudy)
	{
		this.coefStudy = coefStudy;
		setIs_modified_coefStudy(true);
	}

	/**
	 * @return une string comprenant l'instruction SQL pour ajouter l'administrateur à la base de donnée 
	 */
	public String generateInsertSQL() {
		String insertSQL = "INSERT INTO administrator VALUES ('" + this.passwd + "' ,"
				+ this.coefProfile + " , "+this.coefStudy+" , "+this.coefPro +")";
		
		return insertSQL;
	}
	
	/**
	 * @return une string comprenant l'instruction SQL pour supprimer l'administrateur à la base de donnée 
	 */
	public String generateDeleteSQL() {
		String deleteSQL = "DELETE FROM administrator WHERE passwd='"
				+ passwd +"'";
		return deleteSQL;
	}
}
